/**
 * @param {number[]} prices
 * @return {number}
 */
var maxProfit = function (prices) {
  let result = 0
  for (let i = 0; i < prices.length; i++) {
    if (prices[i + 1] < prices[i]) {
      continue
    } else {
      let j = i + 1
      while (j < prices.length) {
        result = Math.max(result, prices[j] - prices[i])
        j++
      }
    }
  }
  return result
};
let prices = [7,6,4,3,1]
maxProfit(prices)